<div class="modal fade " id="add-modal_id" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true" style="z-index: 10000">
    <div class="modal-dialog modal-lg" style="width: 1100px">
        <div class="modal-content">
            <div class="modal-header">

                <h2 class="modal-title" id="myModalLabel">
                    到店信息：
                </h2>
            </div>

            <div class="modal-body">


                <div class="panel panel-default">

                    <div class="panel-body">

                        <table class="table table-hover table-striped" id="modal-table">
                            <thead>
                            <tr>

                                <th>就诊日期</th>
                                <th>本次症状</th>
                                <th>客户状态</th>

                                <th>服务项目</th>
                                <th>检查报告</th>
                                <th>满意度</th>
                                <th>客户反馈</th>
                                <th>购买信息</th>


                            </tr>
                            </thead>
                            <tbody>
                            {% for each in text_dict %}
                                <tr>

                                    <td>{{ each.test_date }}</td>
                                    <td>{{ each.symptom }}</td>
                                    <td>{{ each.get_trail_or_bought_display }}</td>
                                    <td>{{ each.test_treatment }}</td>
                                    <td><a href="#" id="test_result-test_id-{{ each.test_id }}" class="testInfo">查看</a></td>

                                    <td>{{ each.get_satisfaction_display }}</td>
                                    <td><a href="#" id="feedback-test_id-{{ each.test_id }}" class="testInfo">查看</a></td>
                                    <td><a class="btn btn-xs btn-primary testInfo" id="order-test_id-{{ each.test_id }}">购买信息</a></td>


                                </tr>
                                <tr class="hidden">
                                    <td class="infoTd" rowspan="8"></td>
                                </tr>
                            {% endfor %}
                            </tbody>
                        </table>

                    </div>
                </div>


            </div>

            <div class="modal-footer">

                <button type="button" class="btn btn-primary" id="m_close">返 回</button>

            </div>

        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<script>
    $(function () {


        $(".infoTd").click(function () {

            $(this).parent().addClass("hidden");
        });
        $("#m_close").click(function () {

            $('#add-modal_id').modal('hide');
        });
        $("#indoors").click(function () {

            $('#add-modal_id').modal('show');

        });
        $(".testInfo").on("click", function () {
            var trObj = $(this).parent().parent().next('tr')

            $.ajaxSetup({

                data: {csrfmiddlewaretoken: '{{ csrf_token }}'},

            });
            $.ajax({
                    url: '{% url "show_info" %}',
                    type: 'POST',
                    data: {"info": $(this).attr("id")},

                    dataType: 'JSON',
                    success: function (arg) {

                        var result = arg['result']


                        trObj.removeClass("hidden");
                        if(arg['result']) {
                            trObj.children().html("<strong class='text-primary'>"+result[0] + "：</strong>" + result[1]);
                        }else{trObj.children().html("<strong class='text-danger' style='text-align:center'>无记录！</strong>")}

                    }

                }
            );
        })
    })

</script>